<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCouponTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupons', function (Blueprint $table) {
            $table->id();
            $table->string("code", 8)->unique()->comment('券码');
            $table->string("batch_code", 8)->comment('生产批次');
            // 0:待分配 1:已分配待兑换 2:已兑换 -1:已过期
            $table->tinyInteger("status")->default(0)->comment('状态');
            $table->string("valid_type",)->default(0)->comment('有效类型');
            $table->string("valid_dates")->default("366d")->comment('有效天数');
            $table->timestamp("allot_time")->nullable()->comment('分配时间');
            $table->string("accepter_phone", 13)->nullable()->comment('接受人手机');
            $table->timestamp("exchange_time")->nullable()->comment('兑换时间');
            $table->integer('exchange_user_id')->default(0)->comment('兑换人ID');
            $table->integer('exchange_order_id')->default(0)->comment('兑换的订单ID');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupons');
    }
}
